/**
 * Created by gongxun on 16/11/20.
 */

var PdkTableResultLayer = GameCCSBase.extend({
    AtlasLabel_scores : null,
    Image_socres : null,
    scoreBasePoints : null,
    ctor : function(){
        this._super();
        this.loadCocostudio("res/ccs/PdkTableResult.json");

        this.loadUI();
    },

    loadUI : function(){
        this.Image_socres = [];
        this.AtlasLabel_scores = [];
        this.scoreBasePoints = [];
        for (var i = 0; i < 3; i++){
            var Image_socre = mo.seekWidgetByName(this.ccsNode, "Image_score" + i);
            this.Image_socres.push(Image_socre);
            Image_socre.setVisible(false);

            //位置
            this.scoreBasePoints.push(Image_socre.getPosition());

            //分数控件
            var AtlasLabel_score = mo.seekWidgetByName(Image_socre, "AtlasLabel_score" + i);
            AtlasLabel_score.ignoreContentAdaptWithSize(true);
            this.AtlasLabel_scores.push(AtlasLabel_score);

        }
    },

    //显示分数
    setResultScore : function(scores){
        for (var i = 0; i < scores.length; i++){
            this.AtlasLabel_scores[i].stopAllActions();
            if (scores[i] != 0){
                this.Image_socres[i].setVisible(true);
                this.Image_socres[i].setOpacity(255);
                this.Image_socres[i].setPosition(this.scoreBasePoints[i]);
                this.Image_socres[i].runAction(cc.sequence(
                    // cc.fadeIn(0.1),
                    cc.delayTime(0.8),
                    cc.spawn(cc.fadeOut(0.2), cc.moveBy(0.2, cc.p(0, 50))),
                    cc.hide()
                ));

                var showStr = "./" + scores[i];
                if (scores[i] > 0){
                    this.AtlasLabel_scores[i].setProperty(showStr, "res/ccs/pdk/piaofen_add.png", 42, 53, ".");
                }else{
                    this.AtlasLabel_scores[i].setProperty(showStr, "res/ccs/pdk/piaofen_sub.png", 42, 53, ".");
                }
            }else{
                this.Image_socres[i].setVisible(false);
            }
        }
    }
});
